package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyRecordBean;
import stark.common.basic.adaptermutil.StkEmptyProvider;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class CreateRecordAdapter extends StkProviderMultiAdapter<MyRecordBean> {

    public CreateRecordAdapter() {
        addItemProvider(new StkEmptyProvider<>(112));
        addItemProvider(new CreateProvider());
    }

    private boolean isEdit = false;

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class CreateProvider extends BaseItemProvider<MyRecordBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_create_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyRecordBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivCreateRecordItemImg));
            if (isEdit) {
                baseViewHolder.getView(R.id.ivCreateRecordItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivCreateRecordItemSel).setVisibility(View.GONE);
            }
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivCreateRecordItemSel, R.drawable.axuanz);
            } else {
                baseViewHolder.setImageResource(R.id.ivCreateRecordItemSel, R.drawable.aweixuanzhong);
            }
        }
    }

}
